﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhSystemBLL.orderData;
using baseSet.importExport;
using baseSet;
using dhDataAcess.orderLinqDAL;
using dhDataAcess.baseBLL;

namespace dhsystem.produceForm
{
    public partial class FrmproductDate : Form
    {
        string orderNo;
        public FrmproductDate(string _orderNo)
        {
            InitializeComponent();
            orderNo = _orderNo;
        }

        private void FrmproductDate_Load(object sender, EventArgs e)
        {
            textorder.Text = orderNo;
            dGridDetail.Columns[1].ReadOnly = true;
            dGridDetail.Columns[2].ReadOnly = true;
            dGridDetail.Columns[3].ReadOnly = true;
            dGridDetail.Columns[4].ReadOnly = true;
            dGridDetail.Columns[5].ReadOnly = true;
            dGridDetail.Columns[6].ReadOnly = true;
            dGridDetail.Columns[7].ReadOnly = true;
            dGridDetail.Columns[8].ReadOnly = true;
            dGridDetail.Columns[9].ReadOnly = true;
            dGridDetail.Columns[10].ReadOnly = true;
            dGridDetail.Columns[11].ReadOnly = true;
            dGridDetail.Columns[12].ReadOnly = true;
        }
        orderMasterBLL orderMaster = new orderMasterBLL();
        orderDetailBLL orderDetail = new orderDetailBLL();
        orderMasterModel orderMasterRow = new orderMasterModel();
        private void textorder_TextChanged(object sender, EventArgs e)
        {
            BindingSourceorderMasterAdd.DataSource = orderMaster.getorderMasterAllByorderNo(textorder.Text);
            labelorderStatus.DataBindings.Add("text", BindingSourceorderMasterAdd, "orderStatus");
            textorder.DataBindings.Add("text", BindingSourceorderMasterAdd, "orderNo");
            labelcustNum.DataBindings.Add("text", BindingSourceorderMasterAdd, "custNum");
            labelorderDate.DataBindings.Add("text", BindingSourceorderMasterAdd, "orderDate");
            labelreceiveDate.DataBindings.Add("text", BindingSourceorderMasterAdd, "receiveDate");
            labelcustPoNo.DataBindings.Add("text", BindingSourceorderMasterAdd, "custPoNo");
            labelbillNo.DataBindings.Add("text", BindingSourceorderMasterAdd, "billNo");
            labelorderMark.DataBindings.Add("text", BindingSourceorderMasterAdd, "orderMark");
            labeluserNum.DataBindings.Add("text", BindingSourceorderMasterAdd, "userNum");
            labelworkername.DataBindings.Add("text", BindingSourceorderMasterAdd, "workername");
            labelkjf.DataBindings.Add("text", BindingSourceorderMasterAdd, "kjf");
            labelscf.DataBindings.Add("text", BindingSourceorderMasterAdd, "scf");
            labelaccount.DataBindings.Add("text", BindingSourceorderMasterAdd, "account");
            labelparkMark.DataBindings.Add("text", BindingSourceorderMasterAdd, "parkMark");
            labelmark.DataBindings.Add("text", BindingSourceorderMasterAdd, "mark");
            bindingSourceorderDetail.DataSource = orderDetail.getorderDetailByorderNo(textorder.Text);
            labeladdress.DataBindings.Add("text", BindingSourceorderMasterAdd, "address");
            dateTimefuqi.DataBindings.Add("text", BindingSourceorderMasterAdd, "updateDate");
            dGridDetail.DataSource = bindingSourceorderDetail;
            DcolumnSet.colSet(moduleInfo.orderDetail, dGridDetail);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {

            try
            {
                DialogResult result = MessageBox.Show("是否保存订单表信息！", "提示信息", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    //orderMasterRow.orderNo  = orderNo;
                    //orderMasterRow.createDate = dateTimefuqi.Value;
                    //orderMaster.orderMasterUpdate(orderMasterRow);
                    basicSql.getorderupdateDateUpdate(orderNo ,dateTimefuqi .Value .ToString ()); 
                    basicSql.getorderStatusUpdate(orderNo ,"已复期");
                    MessageBox.Show("保存成功");
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
    }
}
